<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Daum에디터 - 파일 첨부</title> 
<script src="/editor/js/popup.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="/editor/css/popup.css" type="text/css"  charset="utf-8"/>
</head>
<body onload="initUploader();">
<div class="wrapper">
	<div class="header">
		<h1>파일 첨부</h1>
	</div>	
	<div class="body">
	<input type="file" id="filesUpload" multiple>
	</input>
		<!-- <dl class="alert">
		    <dt>파일 첨부 확인</dt>
		    <dd>
		    	확인을 누르시면 임시 데이터가 파일첨부 됩니다.<br /> 
				인터페이스는 소스를 확인해주세요.
			</dd>
		</dl> -->
		<ul id="fileList">
			<li class="no-itmes">
		</ul>
	</div>
	<div class="footer">
		<p><a href="#" onclick="closeWindow();" title="닫기" class="close">닫기</a></p>
		<ul>
			<li class="submit"><a href="#" onclick="done2();" title="등록" class="btnlink" id="submit">등록</a> </li>
			<li class="cancel"><a href="#" onclick="closeWindow();" title="취소" class="btnlink">취소</a></li>
		</ul>
	</div>
</div>

</body>
<script type="text/javascript">
// <![CDATA[
	var filesUpload = document.getElementById("filesUpload");
	var fileList = document.getElementById("fileList");
	var submit = document.getElementById("submit");
    
		
		
	function done(files) {
		
		
		
		if (typeof(execAttach) == 'undefined') { //Virtual Function
	        return;
	    }
		alert(files[0].name);
		alert(files[0].value);
		alert(files[0].size);
		var mockdata = {};
		for(var i=0; i<files.length; i++){
			 var _mockdata = {
					'attachurl': 'testy',
					'filemime': 'image/gif',
					'filename': files[i].name,
					'filesize': files[i].size
				}; 
			 execAttach(_mockdata);		
		}
		
		closeWindow();
	}
		

	function initUploader(){
	    var _opener = PopupUtil.getOpener();
	    if (!_opener) {
	        alert('잘못된 경로로 접근하셨습니다.');
	        return;
	    }
	    
	    var _attacher = getAttacher('file', _opener);
	    registerAction(_attacher);
	}
	 function done2() {
		done(filesUpload.files);
	} 
	
</script>
</html>
